home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_c / cuj0696.zip / DWYER.ZIP / GAP.TST / GAPMNSD.C < prev    next >
C/C++ Source or Header  |  1996-02-23  |  978b  |  25 lines

  1. /* ============ */
  2. /* GapMnSd.c    */
  3. /* ============ */
  4. #include <defcodes.h>
  5. #include <math.h>
  6. /* ==================================================================== */
  7. /* CalcGapMeanStdDev - Calculates Mean & Standard Deviation for Gap Test*/
  8. /* ==================================================================== */
  9. void
  10. CalcGapMeanStdDev(int NumGaps, double BaseProb, double *Mean,
  11.         double *StdDev)
  12. {
  13.     /* ---------------------------------------------------- */
  14.     /* NumGaps  (IN)  - Number of Gaps to be Tabulated        */
  15.     /* BaseProb (IN)  - Probability Measure (GapHi-GapLo)   */
  16.     /* Mean     (OUT) -    Average Number of Variates Required */
  17.     /* StdDev   (OUT) - Corresponding Standard Deviation    */
  18.     /*                                */
  19.     /* These equations were taken from Knuth, Vol 2, p 535  */
  20.     /* ---------------------------------------------------- */
  21.     *Mean = NumGaps/BaseProb;
  22.  
  23.     *StdDev = sqrt(NumGaps * (1-BaseProb)) / BaseProb;
  24. }
  25.